package com.wanhong.springboot.ssm.framework.configuration;


import com.wanhong.springboot.ssm.framework.interceptor.UserAuthInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author w_yu
 * @date 2020/11/26 16:01
 * @desc
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {


    @Bean
    public UserAuthInterceptor userAuthInterceptor(){
        return new UserAuthInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userAuthInterceptor()).excludePathPatterns(this.getExcludePath());
    }

    private List<String> getExcludePath(){
        List<String> paths = new ArrayList<>();
        paths.add("/error");
        return paths;
    }


}


